<div style="width:1000px" align="left">
	{if $offer_cats && $item_cats && $title_offer}
	<div id="product_offer">
        <div class="product_offer_top">
        	<div class="offer_title">{$title_offer}</div>
            
            {foreach from=$offer_cats item=cat name=offer_cat}
                <div class="offerdes_tab{if $smarty.foreach.offer_cat.first} offeractive{/if} offer_tabs" onclick="show_offer_tab(this, {$cat.id},'offer_tabs','offertab_');">
                    <div class="offerdes_tab_r">
                        <div class="offerdes_tab_c">
                           {$cat.name}
                        </div>
                    </div>
                </div>
            {/foreach}
            <div class="c"></div>
        </div>
        <div class="product_offer_content">
        	{if $adv_status}
               <div class="fl" style="width:200px;margin:10px 2px 10px 0">
                {if $type_display==1}
                    {if $url_detail}<a href="{$url_detail}">{/if}<img src="{$adv_banner}" width="{$adv_width}"/>{if $url_detail}</a>{/if}
                {else}
                    <embed src="{$adv_banner}"  wmode="transparent" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="{$adv_width}" height="{$adv_height}"></embed>
                {/if}
               </div>
            {/if}
        	
            {if $adv_status}
            <div style="width:798px" class="fl">
            {/if}
            {foreach from=$item_cats item=item_cat key=catid name=offer_cat_item}
            <div class="offertab_content" id="offertab_{$catid}">
                {foreach from=$item_cat item=item key=itemid name=offer_item}
                	{if $adv_status}
                    	{assign var='firt_col' value=0}
                	{elseif $smarty.foreach.offer_item.iteration == 0 || !(($smarty.foreach.offer_item.iteration-1)%4)}
                    	{assign var='firt_col' value=1}
                    {else}
                    	{assign var='firt_col' value=0}
                    {/if}
                    
                    {if $smarty.foreach.offer_item.iteration>1 && (($adv_status && !(($smarty.foreach.offer_item.iteration-1)%3)) || (!$adv_status && !(($smarty.foreach.offer_item.iteration-1)%4)))}
                        <div class="c"></div>
                    {/if}
                    <div class="offer_item fl" style="{if $firt_col}margin-left:0;width:242px{elseif !$adv_status}width:240px{/if}" id="offer_item_{$smarty.foreach.offer_cat_item.iteration}_{$smarty.foreach.offer_item.iteration}">
                    	<div style="position:relative">
                        	{if $item.sale_off != ''}
                        		<div class="home_sale_off" title="Sale off {$item.sale_off}%"><span>{$item.sale_off}</span></div>
                            {/if}
                            
                            {if $item.image}
                                <a href="{$item.url}">
                                    <img src="{$item.image}" width="235" height="150"/>
                                </a>
                            {else}
                                <div style="background:url(style/images/no-images-35x35.gif) no-repeat center">
                                    <a href="{$item.url}"><img src="style/images201005/space.gif" width="200" height="150"/></a>
                                </div>
                            {/if}
                        </div>
                        <a href="{$item.url}">
                            {$item.name}
                        </a>
                        <div title="Giá" class="price">{$item.price}</div>
                        {if $item.price_out}<div title="Giá thị trường" class="price_out">{$item.price_out}</div>{/if}
                        
                        {if $item.offer}
                        <div class="home_offer_title">Khuyến mại</div>
                        <div class="home_offer_content">{$item.offer}</div>
                        {/if}
                        
                        <div class="list_add_cart" style="margin:auto"><a onclick="add_to_cart({$item.id},{$item.price_num})"></a></div>
                    </div>
                {/foreach}
                
                <script>
				{literal}
				jQuery(document).ready(function(){
				{/literal}
				
					auto_resize('offer_item_{$smarty.foreach.offer_cat_item.iteration}_',{$smarty.foreach.offer_item.total},{if $adv_status}3{else}4{/if});
					
					{if $smarty.foreach.offer_cat_item.iteration>1}
					jQuery('#offertab_' + {$catid}).hide();
					
					{/if}
					
				{literal}
				});
				{/literal}
				</script>
               
                <div class="c"></div>
            </div>
            {/foreach}
            
            {if $adv_status}
            </div>
            {/if}
        </div>
        {*<!--<div class="product_offer_content_botom"></div>-->*}
    </div>
    <div class="c"></div>  
    {/if}

    {if $is_admin}
        {$begin_form}
  			<div style="cursor:pointer;margin:10px 0" onclick="jQuery('#admin_item_offer').toggle();"><strong>Quản lý SP Khuyến mại</strong></div>
            <div style=";margin:10px 0" id="admin_item_offer" class="hide">
                {$msg}<br />
                <table cellpadding="5" cellspacing="0" border="0" width="100%">
                   <tr>
                     <td align="right"><strong>Tiêu đề:</strong></td>
                     <td><input type="text" name="title_offer" value="{$title_offer}" style="width:300px"/></td>
                  </tr>
                   <tr>
                     <td>&nbsp;</td>
                     <td>&nbsp;</td>
                  </tr>
                   <tr>
                     <td width="23%"><strong>Danh mục</strong></td>
                              <td width="77%"><strong>ID sản phẩm (cách nhau bởi dấu (,) VD: 1,2,34)</strong></td>
                  </tr>
                  {foreach from=$item_cat_offer item=cat_offer}
                   <tr>
                        <td nowrap="nowrap">
                          <b>[{$cat_offer.id}]</b> {$cat_offer.name}
                        </td>
                        <td>
                           <input type="text" name="item_cats[{$cat_offer.id}]" value="{$cat_offer.item_ids}" style="width:100%"/>
                       </td>
                   </tr>
                   {if $cat_offer.sub}
                       <tr>
                           <td colspan="2" class="pl15">
                              &raquo; <span style="cursor:pointer" onclick="jQuery('.cat_offer_sub_{$cat_offer.id}').toggle();">[Danh mục con]</span>
                           </td>
                       </tr>
                       {foreach from=$cat_offer.sub item=subcat_offer}
                       <tr class="cat_offer_sub_{$cat_offer.id}{if !$cat_offer.sub_display} hide{/if}">
                            <td nowrap="nowrap" class="pl15">
                              ------- <b>[{$subcat_offer.id}]</b> {$subcat_offer.name}
                            </td>
                            <td>
                               <input type="text" name="item_cats[{$subcat_offer.id}]" value="{$subcat_offer.item_ids}" style="width:100%"/>
                           </td>
                       </tr>
                       {/foreach}
                   {/if}
                    <tr>
                        <td colspan="2">
                          <hr />
                       </td>
                   </tr>
                   {/foreach}
                </table>   
                <input type="submit" name="submit" value="Cập nhật"/> <input type="submit" name="submit" value="Xóa tất cả" onclick="return confirm('Bạn có chắc chắ muốn xóa tất cả các ID không?');"/> 
        </div>
        
        
        
        	<div style="cursor:pointer;" onclick="jQuery('#AdvItemOffer_config').toggle()"><strong>Cấu hình AdvItemOffer</strong></div>
            <div id="AdvItemOffer_config" class="hide">
            <table cellpadding="4" cellspacing="0">
                <tr>
                    <td>
                        Tình trạng:
                    </td>
                    <td>
                        <select name="status"> {$status_option}</select>
                    </td>
                </tr>
                <tr>
                    <td>
                      Loại hiển thị:
                    </td>
                    <td>
                        <select name="type">{$type_option}</select>
                    </td>
                </tr>
                <tr>
                    <td>
                        Url:            
                    </td>
                    <td>
                        <input type="text" name="url" value="{$url}" />
                    </td>
                </tr>
                 <tr>
                    <td>
                       Upload:           
                    </td>
                    <td>
                       <input type="file" name="banner"/> <br />
        <strong>Ảnh</strong> {$adv_width}x...( .gif , .jpg ); <strong>Flash</strong>   {$adv_width}x{$adv_height}... ( .swf )
                    </td>
                </tr>
                 <tr>
                    <td>
                      
                    </td>
                    <td>
                       <input type="submit"  name="submit" value="Cập nhật Quảng cáo" />
                    </td>
                </tr>
           </table>
            </div>
        {$end_form}
    {/if}
</div>